﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Test - Open API Control Panel
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    [<%= Html.ActionLink("Get","Test","API") %>] [Post]
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
        <tr>
            <td valign="top">
                <% Html.BeginForm(); %>
                <fieldset title="Request URL">
                    <legend>Request URL</legend>
                    <div class="editor-label">
                        Select API Method:
                    </div>
                    <div class="editor-field">
                        <% =Html.DropDownList("ddlAPI_METHOD", ViewData["API_METHOD"] as SelectList, new { @style = "width:350px", onchange = "this.form.submit();" })%>
                    </div>
                    <div class="editor-label">
                        API Method:
                    </div>
                    <div class="editor-field">
                        <% =Html.TextBox("api_method", ViewData["SELECTED_METHOD"], new { @style = "width:350px" })%>
                    </div>
                </fieldset>
                <%if (!string.IsNullOrEmpty(ViewData["SELECTED_METHOD"].ToString()))
                  {
                %>
                <fieldset title="Un Sign Arguments">
                    <legend>Un Sign Arguments</legend>
                    <%
                        foreach (ArgumentInfo unSignArgument in ViewData["UnSignArgumets"] as ArrayList)
                        {
                    %>
                    <div class="editor-label">
                        <%=unSignArgument.Name %>:
                    </div>
                    <div class="editor-field">
                        <% =Html.TextBox(unSignArgument.Name, unSignArgument.Value, new { @style = "width:250px" })%>
                    </div>
                    <%
                        }                          
                    %>
                </fieldset>
                <fieldset title="Sign Arguments">
                    <legend>Sign Arguments</legend>
                    <%
                        foreach (ArgumentInfo argument in ViewData["SignArgumets"] as ArrayList)
                        {
                    %>
                    <div class="editor-label">
                        <%=argument.Name%>:
                    </div>
                    <div class="editor-field">
                        <% =Html.TextBox(argument.Name, argument.Value, new { @style = "width:250px" })%>
                    </div>
                    <%
                        }                          
                    %>
                </fieldset>
                <fieldset title="API Secret">
                    <legend>API Secret </legend>
                    <%
                        ArgumentInfo api_secret_argument = ViewData["API_SECRET_ARGUMENT"] as ArgumentInfo;
                        if (api_secret_argument != null)
                        {
                    %>
                    <div class="editor-label">
                        <%=api_secret_argument.Name %>:
                    </div>
                    <div class="editor-field">
                        <% =Html.TextBox("txtAPI_SECRET", api_secret_argument.Value, new { @style = "width:250px" })%>
                    </div>
                    <%
                        } %>
                </fieldset>
                <fieldset title="API Signature">
                    <legend>API Signature </legend>
                    <div class="editor-label">
                        API Signature
                    </div>
                    <div class="editor-field">
                        <% =Html.TextBox("api_signature", ViewData["API_SIGNATURE"], new { @style = "width:250px" })%>
                    </div>
                </fieldset>
                <p>
                    <input type="submit" id="AjaxGetAPISignature" name="AjaxGetAPISignature" value="Get API Signature" />
                    <input type="button" id="btnPost" name="btnPost" value="Post" />
                </p>
                <%
                    } 
                %>
                <% Html.EndForm(); %>
            </td>
            <td valign="top">
                <fieldset title="Test Data">
                    <legend>Test Data</legend>
                    <div class="editor-label">
                        oauth_nonce
                    </div>
                    <div class="editor-field">
                        <% =Html.TextBox("txtOAUTH_NONCE", Utility.StringHelper.GetGuidString(), new { @style = "width:250px" })%>
                    </div>
                    <div class="editor-label">
                        oauth_timestamp
                    </div>
                    <div class="editor-field">
                        <% =Html.TextBox("txtOAUTH_TIMESTAMP", APIHelper.GetTimeStemp(), new { @style = "width:250px" })%>
                    </div>
                    <div class="editor-label">
                        oauth_version
                    </div>
                    <div class="editor-field">
                        <% =Html.TextBox("txtOAUTH_VERSION", "1.0", new { @style = "width:250px" })%>
                    </div>
                </fieldset>
            </td>
        </tr>
    </table>

    <script type="text/javascript" language="javascript">

        //json: 提交请求令牌
        $().ready(function() {
            $("#btnPost").click(function() {
                this.form.action = '/API/Rest/';
                this.form.submit();
            })
        })
        

    </script>

</asp:Content>
